/**
 * PartnerEntityHandlerBean.java
 * 
 */

package com.example.managedbeans;



import java.util.ArrayList;
import java.util.List;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;


import com.example.entities.*;
import com.example.service.*;





public class PartnerEntityHandlerBean
{
  private String partnerName;
  private String partnerCity;
  private String partnerContactMail;
  private  List<Partner> partnerList;

  
  

public PartnerEntityHandlerBean()
{
	
}
    	




	public String getPartnerName() {
	return partnerName;
}





public void setPartnerName(String partnerName) {
	this.partnerName = partnerName;
}





public String getPartnerCity() {
	return partnerCity;
}





public void setPartnerCity(String partnerCity) {
	this.partnerCity = partnerCity;
}





public String getPartnerContactMail() {
	return partnerContactMail;
}





public void setPartnerContactMail(String partnerContactMail) {
	this.partnerContactMail = partnerContactMail;
}





public List<Partner> getPartnerList() {
	return partnerList;
}





	public String insertNewPartner()
    {   
		
    	Partner partner = new Partner();
    	partner.setName(this.partnerName);
    	partner.setCity(this.partnerCity);
    	partner.setContactMail(this.partnerContactMail);
    	PartnerHandler ph = new PartnerHandler();
    	ph.create(partner);
    	return "viewid?faces-redirect=true";
    }
	
	public String getAllPartners()
	{
		PartnerHandler ph = new PartnerHandler();
		partnerList = ph.getAllPartner();
		return "true";		
	}
	
	public String delete()
	{
		PartnerHandler ph = new PartnerHandler();
		ph.deleteByPartnerName(this.partnerName);
		return "true";
	}
	public String test()
	{
		System.out.println("Test");
		return "failure";
	}
    
 
}
